<template>
  <div>
    <!-- 待收货内容样式排版 -->
    <ul>
      <li v-for="(item, index) in recordsGetVal" :key="index">
        <!-- 上部结构 -->
        <div class="descript_cont">
          <span>{{ item.prodName }}</span>
          <span>&gt;</span>
        </div>
        <!-- 中部结构 -->
        <div class="count_order">
          <div class="zuo"></div>
          <div class="you">
            <h3>{{ item.title }}</h3>
            <p class="p1"><span>发货时间</span>{{ item.orderTime }}</p>
            <p><span>下单人</span>{{ item.orderUserName }}</p>
          </div>
        </div>
        <!-- 下部状态按钮结构 -->
        <div class="btn_sub">
          <!-- 添加收货点击事件 -->
          <van-button
            color="#003399"
            size="small"
            @click="shouHuo(item.serialNo)"
            >{{ butVal }}</van-button
          >
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { GetOrderGetData, QueRenShouhuo } from "@/request/api";
export default {
  data() {
    return {
      recordsGetVal: [],
      butVal: "评价",
      // 保存的订单号
      // serialNoVal: "",
    };
  },
  created() {
    GetOrderGetData({
      current: 1,
      size: 2,
      keyword: "",
    }).then((res) => {
      this.recordsGetVal = res.data.records;
      console.log(this.recordsGetVal);
      this.recordsGetVal.map((item) => {
        if (item.status == 0) {
          this.butVal = "发货";
        } else if (item.status == 10) {
          this.butVal = "收货";
        } else if (item.status == 20) {
          this.butVal = "评价";
        } else if (item.status == 30) {
          this.butVal = "查看评价";
        }
      });
    });
  },
  methods: {
    shouHuo(val) {
      // 添加弹窗确认效果
      this.$dialog
        .confirm({
          message: "弹窗内容",
        })
        .then(() => {
          // 点击确认时发送收货请求，进行收货操作
          QueRenShouhuo({
            serialNo: val,
          }).then((res) => {
            console.log(res);
          });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>
 
<style lang = "less" scoped>
li {
  width: 100%;
  background-color: white;
  box-sizing: border-box;
  margin-top: 0.1rem;
  .descript_cont {
    height: 0.5rem;
    line-height: 0.5rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #efefef;
    padding: 0 0.2rem;
  }
  /* 订单描述的具体内容样式 */
  .count_order {
    width: 100%;
    padding: 0.2rem;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    .zuo {
      height: 0.7rem;
      width: 0.7rem;
      background-color: wheat;
      margin-right: 0.1rem;
    }
    .you {
      height: 0.7rem;
      flex: 1;
      background-color: yellow;
      p {
        span {
          margin-right: 0.1rem;
        }
      }
      .p1 {
        line-height: 0.4rem;
      }
    }
  }
  .btn_sub {
    height: 0.5rem;
    padding: 0.1rem 0.2rem;
    box-sizing: border-box;
    border-top: 1px solid #efefef;
    .van-button {
      float: right;
      border-radius: 0.15rem;
      padding: 0 0.15rem;
    }
  }
}
</style>